import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:practice/res/color.dart';
import 'package:practice/widget/image_widget.dart';

class MyAppbar extends StatelessWidget implements PreferredSizeWidget {
  final Widget? title;
  final Widget? leading;
  final Color backgroundColor;

  final List<Widget>? actions;
  final bool? centerTitle;
  final double? elevation;
  final PreferredSizeWidget? bottom;
  final Color themeColor;
  final SystemUiOverlayStyle? systemUiOverlayStyle;

  const MyAppbar({
    Key? key,
    this.title,
    this.leading,
    this.backgroundColor = Colors.white,
    this.centerTitle = true,
    this.actions,
    this.elevation = 0,
    this.bottom,
    this.themeColor = Colour.text_7,
    this.systemUiOverlayStyle = SystemUiOverlayStyle.dark,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return AppBar(
      backgroundColor: backgroundColor,
      title: title,
      titleTextStyle: TextStyle(
        fontWeight: FontWeight.bold,
        fontSize: 17,
        color: themeColor,
      ),
      iconTheme: IconThemeData(
        color: themeColor,
      ),
      leading: leading ??
          IconButton(
              iconSize: 22,
              splashRadius: 22,
              padding: const EdgeInsets.all(4),
              color: themeColor,
              onPressed: () {
                Get.back();
              },
              icon: const Icon(Icons.arrow_back_ios_rounded)),
      actions: actions,
      centerTitle: centerTitle,
      elevation: elevation,
      bottom: bottom,
      systemOverlayStyle: systemUiOverlayStyle,
    );
  }

  @override
  // TODO: implement preferredSize
  Size get preferredSize => const Size.fromHeight(48);
}